<script setup>
import { watch } from 'vue';
import useUserStore from '@/store/user';
import { getUserinfo } from '@/api/auth'
import useApiCallback from '@/hooks/useApiCallback';

const userStore = useUserStore()
const [updateUserinfo] = useApiCallback(async () => {
  const result = await getUserinfo()
  if (result.code === 0) {
    userStore.userinfo = result.data
  }
})
watch(() => userStore.isLogined, async (isLogined) => {
  if (!isLogined) return
  await updateUserinfo()
}, {
  immediate: true
})
</script>

<template>
  <router-view />
</template>

<style lang="sass">

@import '@/assets/style/common.scss'

html, body
  background-color: rgba(235,235,235,0.8)

#app
  font-family: Avenir, Helvetica, Arial, sans-serif
  height: 100vh
  position: relative
  z-index: 0
</style>
